package scuts.core;

import haxe.macro.Expr;
#if macro
import scuts.macro.Parse;
#end


class LazyExpr
{
  @:macro public static function lazy(expr:ExprRequire<Dynamic>):Expr 
  {
    return Parse.parse("{var r = null; function () { if (r == null) r = $0; return r; }}", [expr], expr.pos);
  }
}
 
class LazyDynamic 
{
  public static function lazyConstant<T>(value:T):Void->T 
  {
    return function () return value;
  }
  
}